/**
 * ClientParamsServiceImpl.java
 * Created at 2017-8-8
 * Created by xieshuang
 * Copyright (C) 2017 BROADTEXT SOFTWARE, All rights reserved.
 */
package com.broadtext.rms.basic.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.broadtext.common.exp.DaoException;
import com.broadtext.common.exp.ServiceException;
import com.broadtext.common.repository.EntityDao;
import com.broadtext.common.service.impl.EntityServiceImpl;
import com.broadtext.common.utils.UUIDUtils;
import com.broadtext.rms.basic.model.TtClientParams;
import com.broadtext.rms.basic.service.IClientParamsService;

/**
 * <p>ClassName: ClientParamsServiceImpl</p>
 * <p>Description: Client参数配置服务实现类</p>
 * <p>Author: xieshuang</p>
 * <p>Date: 2017-8-8</p>
 */
@Service("clientParamsService")
public class ClientParamsServiceImpl extends EntityServiceImpl<TtClientParams> implements IClientParamsService {

    /**
     * <p>
     * Description: 注解入相关DAO
     * </p>
     * 
     * @param entityDao
     */
    @Autowired
    @Qualifier("clientParamsDao")
    public void setEntityDao(EntityDao<TtClientParams> entityDao) {
        super.entityDao = entityDao;
    }
    
    /**
     * 
     * <p>Description: 新增or编辑</p>
     * @param t 对象
     * @param currentUser 当前登录人
     * @return 保存标志
     * @throws ServiceException 异常
     * @throws DaoException 异常
     */
	public void saveOrUpdate(TtClientParams t, String currentUser) throws ServiceException {
		//返回值
        if (!"".equals(t.getPkId())) {
               //编辑
                t.setUpdateUser(currentUser);
                t.setUpdateDate(new Date());
                this.updateRecord(t);
            
        } else {
            //新增  
            	t.setPkId(UUIDUtils.getUUID());
                t.setCreateUser(currentUser);
                t.setCreateDate(new Date());
                t.setUpdateUser(currentUser);
                t.setUpdateDate(new Date());
                t.setDelFlag("0");
                this.insertRecord(t);
        }
	}

	/**
     * 
     * <p>Description: 批量删除</p>
     * @param idArray ID
     * @param sysUser 当前操作用户
     * @throws ServiceException 异常
     */
	 @Override
	 public void deleteByIds(String[] idArray, String sysUser) throws ServiceException {
	            for (String id : idArray) {
	            	TtClientParams model;
	                model = new TtClientParams();
	                model.setPkId(id);
	                //判断逻辑的准确性，代码走一个差
	                if (model != null) {
	                    model.setDelFlag("1");
	                    model.setUpdateUser(sysUser);
	                    model.setUpdateDate(new Date());
	                    super.updateRecord(model);
	                }
	            }
	 }
	 
	/**
	 * 
	 * <p>
	 * Description: 获取ftpParams下拉框选项
	 * </p>
	 * 
	 * @return 结果集
	 * @throws DaoException
	 */
	@SuppressWarnings("unchecked")
	public Object getFtpParamsOptions() throws DaoException {
		List<Object> list;
		list = new ArrayList<Object>();
		// 临时
		list = this.entityDao.findByProperty("com.broadtext.rms.basic.model.TtClientParams.getFtpParamsOptions",
						null);
		return list;
	}
	
	/**
	 * 
	 * <p>Description: 获取clientParams下拉框选项</p>
	 * @return 结果集
	 * @throws DaoException 异常
	 */
	@SuppressWarnings("unchecked")
	public Object getClientOptions() throws DaoException {
		List<Object> list;
		list = new ArrayList<Object>();
		// 临时
		list = this.entityDao.findByProperty("com.broadtext.rms.basic.model.TtClientParams.getClientOptions",
						null);
		return list;
	}

}
